import request from './network'

/**
 * 获取解决文案
 * @param {*} severityTypeOf 严重度类型
 * @param {*} skinTypeKey 测肤类型
 * @param {*} skinKey 严重度/类别
 */
export function getSolutionText(phone, severityTypeOf, skinTypeKey, skinKey) {
  let url = ''
  if (severityTypeOf === 'number') { 
    // 分级
    url = 'smms/v1/solution/level/key/list'
  }else if(severityTypeOf === 'string'){
    // 分类
    url = 'smms/v1/solution/key/list'
  }
  return request({
    url,
    data: {
      phone,
      skinTypeKey,
      skinKey
    }
  })
}

/**
 * 获取推荐的产品（根据检测项）
 * @param {*} token 
 * @param {*} key 检测项
 */
export function getProductRecommend(token, key) {
  return request({
    url: 'smms/v1/goods/mpms/list',
    header: {
      Authorization: 'Bearer ' + token
    },
    data: {
      key
    }
  })
}

// 获取产品详情
export function getProductDetail(token, goodsId) {
  return request({
    url: 'smms/v1/goods/' + goodsId,
    header: {
      Authorization: 'Bearer ' + token
    },
  })
}


// 获取ai定制中推荐的产品
export function getAiProductRecommend(token, data) {
  return request({
    url: 'mpms/v1/goods/list',
    header: {
      Authorization: 'Bearer ' + token
    },
    data
  })
}

// 获取ai定制中推荐的产品详情
export function getAiProductRecommendDetail(token, goodsId) {
  return request({
    url: 'mpms/v1/goods',
    header: {
      Authorization: 'Bearer ' + token
    },
    data: {
      id: goodsId
    }
  })
}

/**
 *  获取上一次的水分占比
 * @param {*} token 
 */
export function getLastMoisturePercentApi(data) {
  return request({
    url: `sbm/v1/mini/skin/lastTime?phone=${data.phone}&type=${data.type}&id=${data.id}`,
  })
}

